home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc1 / chktex.lha / chktex / deweb.in < prev    next >
Text File  |  1996-04-30  |  2KB  |  127 lines

  1. #! @PERL5@
  2.  
  3. #  deweb v1.1, kills the C sections of a CWEB file, for passing to ChkTeX.
  4. #  Copyright (C) 1996 Jens T. Berger Thielemann
  5. #
  6. #  This program is free software; you can redistribute it and/or modify
  7. #  it under the terms of the GNU General Public License as published by
  8. #  the Free Software Foundation; either version 2 of the License, or
  9. #  (at your option) any later version.
  10. #
  11. #  This program is distributed in the hope that it will be useful,
  12. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #  GNU General Public License for more details.
  15. #
  16. #  You should have received a copy of the GNU General Public License
  17. #  along with this program; if not, write to the Free Software
  18. #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. #
  20. #  Contact the author at:
  21. #        Jens Berger
  22. #        Spektrumvn. 4
  23. #        N-0666 Oslo
  24. #        Norway
  25. #        E-mail: <jensthi@ifi.uio.no>
  26. #
  27. #
  28. #
  29.  
  30. print STDERR "DeWEB v1.0 - Copyright 1996 Jens T. Berger Thielemann\n";
  31.  
  32. undef $/;
  33. $texmode = 1;
  34. $_ = <>;
  35.  
  36. while(/\@/)
  37. {
  38.     &out($`);
  39.     $_ = $';
  40.  
  41.     if(/^@/) {
  42.     $_ = $'; #'
  43.     &out('@');
  44.            next; 
  45.     }
  46.  
  47.     if(/^([\s\n])/) {
  48.     $_ = $'; #'
  49.     print "\n" if $1 eq "\n";
  50.     $texmode = 1;
  51.     next;
  52.     }
  53.  
  54.  
  55.     if(/^[cpd]/i) {
  56.     $_ = $'; #'
  57.     $texmode = 0;
  58.     next;
  59.     }
  60.  
  61.     if(/^\,/i) {
  62.     $_ = $'; #'
  63.         print '\,'; 
  64.     next;
  65.     }
  66.  
  67.     if(/^\//i) {
  68.     $_ = $'; #' 
  69.         print '\\';
  70.     next;
  71.     }
  72.  
  73.     if(/^[h\&\|\;\#\+]/i || /^i.*/i) {
  74.     $_ = $'; #'
  75.     next;
  76.     }
  77.        
  78.  
  79.     if(/^\*[0-9\*]?((.|\n)*?\.)/) {
  80.     $_ = $'; #'
  81.     print $1;
  82.     $texmode = 1;
  83.     next;
  84.     }
  85.  
  86.     if(/^[<(^.t!]((.|\n)*?)\@\>/i) {
  87.     $_ = $'; #'
  88.     print '{'.$1.'}';
  89.     $texmode = 0;
  90.     next;
  91.     }
  92.  
  93.     if(/^[=]((.|\n)*?)\@\>/) {
  94.     $_ = $'; #'
  95.     print &printnl($1);
  96.     next;
  97.     }
  98.  
  99.     if(/^[fsl](\s+\S+\s+\S+)|^\'(.|\n)*?\'|^\[((.|\n)*?)\@\]/i) {
  100.     $_ = $'; #'
  101.     print &printnl($+);
  102.     next;
  103.     }
  104.  
  105.     @line = split(/\n/, $_, 2);
  106.     print STDERR "Unknown opcode, ignored. Buffer:\n$line[0]\n";
  107.  
  108.  
  109. print $_;
  110.  
  111. sub printnl {
  112.     my($foo);
  113.     if(defined $_[0]) {
  114.     $foo = $_[0];
  115.     $foo =~ s/.//g;        # Remember, . doesn't match \n
  116.     } else {
  117.     $foo = "";
  118.     }
  119.     $foo;
  120. }
  121.  
  122. sub out {
  123.     print $texmode? $_[0] : &printnl($_[0]);
  124. }
  125.  
  126.